using ClownFish;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;

internal static class Class30
{
	private sealed class Class31
	{
		public Class6 class6_0;

		public string[] string_0;
	}

	private static Hashtable hashtable_0 = new Hashtable(4096);

	public static Class6 smethod_0(this Type type_0, bool bool_0)
	{
		if (type_0 == null)
		{
			throw new ArgumentNullException("itemType");
		}
		Class6 @class = Class30.hashtable_0[type_0] as Class6;
		if (@class == null)
		{
			bool flag = false;
			lock (Class30.hashtable_0.SyncRoot)
			{
				@class = (Class30.hashtable_0[type_0] as Class6);
				if (@class == null)
				{
					@class = Class30.smethod_1(type_0);
					Class30.hashtable_0[type_0] = @class;
					flag = type_0.smethod_8();
				}
			}
			if (flag)
			{
				@class.method_6();
			}
		}
		if (bool_0 && BuildManager.int_1 == 1 && @class.method_12() == Enum0.const_0)
		{
			BuildManager.smethod_0(type_0);
		}
		return @class;
	}

	private static Class6 smethod_1(Type type_0)
	{
		MemberInfo[] members = type_0.GetMembers(BindingFlags.Instance | BindingFlags.Public);
		int num = 0;
		MemberInfo[] array = members;
		for (int i = 0; i < array.Length; i++)
		{
			MemberInfo memberInfo = array[i];
			if (memberInfo.MemberType == MemberTypes.Field || memberInfo.MemberType == MemberTypes.Property)
			{
				num++;
			}
		}
		Class6 @class = new Class6(type_0, num);
		MemberInfo[] array2 = members;
		for (int j = 0; j < array2.Length; j++)
		{
			MemberInfo memberInfo2 = array2[j];
			if ((memberInfo2.MemberType == MemberTypes.Field || memberInfo2.MemberType == MemberTypes.Property) && (memberInfo2.MemberType != MemberTypes.Property || !(memberInfo2 as PropertyInfo).smethod_9()))
			{
				DbColumnAttribute dbColumnAttribute = memberInfo2.GetAttribute<DbColumnAttribute>() ?? new DbColumnAttribute();
				Class12 class2 = Class15.smethod_0(memberInfo2);
				if (!class2.vmethod_2().smethod_5())
				{
					if (!dbColumnAttribute.IgnoreLoad && !class2.vmethod_4())
					{
						dbColumnAttribute.IgnoreLoad = true;
					}
					if (!dbColumnAttribute.IgnoreLoad)
					{
						if (class2.vmethod_2().CheckTypeIsModle())
						{
							dbColumnAttribute.bool_0 = true;
							if (!class2.vmethod_2().smethod_6())
							{
								dbColumnAttribute.IgnoreLoad = true;
							}
						}
						else if (string.IsNullOrEmpty(dbColumnAttribute.Alias))
						{
							dbColumnAttribute.Alias = memberInfo2.Name;
						}
					}
					@class.method_9(dbColumnAttribute, class2);
				}
			}
		}
		return @class;
	}

	public static void smethod_2(Class9 class9_0, object object_0)
	{
		if (class9_0 == null)
		{
			throw new ArgumentNullException("row");
		}
		if (object_0 == null)
		{
			throw new ArgumentNullException("item");
		}
		if (class9_0.object_0 == null)
		{
			class9_0.object_0 = new Class30.Class31
			{
				string_0 = class9_0.method_3(),
				class6_0 = object_0.GetType().smethod_0(true)
			};
		}
		Class30.smethod_3(class9_0, object_0, null);
	}

	private static void smethod_3(Class9 class9_0, object object_0, string string_0)
	{
		Type type = object_0.GetType();
		Class30.Class31 @class = (Class30.Class31)class9_0.object_0;
		Class6 class6_ = @class.class6_0;
		if (@class.class6_0.method_10() != type)
		{
			@class.class6_0 = type.smethod_0(true);
		}
		foreach (KeyValuePair<string, Class34> current in @class.class6_0.method_8())
		{
			if (!current.Value.method_1().IgnoreLoad)
			{
				if (current.Value.method_1().bool_0)
				{
					object obj = Activator.CreateInstance(current.Value.method_3());
					current.Value.method_5(object_0, obj);
					string string_;
					if (string.IsNullOrEmpty(current.Value.method_1().SubItemPrefix))
					{
						string_ = string_0;
					}
					else if (current.Value.method_1().SubItemPrefix == "*")
					{
						string_ = string_0 + (current.Key + ".");
					}
					else
					{
						string_ = string_0 + current.Value.method_1().SubItemPrefix;
					}
					Class30.smethod_3(class9_0, obj, string_);
					@class.class6_0 = class6_;
				}
				else
				{
					Class30.smethod_4(class9_0, object_0, current.Value, string_0);
				}
			}
		}
	}

	private static bool smethod_4(Class9 class9_0, object object_0, Class34 class34_0, string string_0)
	{
		string[] string_ = ((Class30.Class31)class9_0.object_0).string_0;
		string value = string_0 + class34_0.method_1().Alias;
		int num = string_.FindIndex(value);
		if (num < 0)
		{
			return false;
		}
		object obj = class9_0.method_1(num);
		return DBNull.Value.Equals(obj) || class34_0.method_5(object_0, obj);
	}
}
